<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Encode binary data before returning it from an UDF</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.sqlite-udf-encode-binary" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sqlite_udf_encode_binary</h1>
  <p class="verinfo">(PHP 5 &lt; 5.4.0, PECL sqlite &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">sqlite_udf_encode_binary</span> &mdash; <span class="dc-title">Encode binary data before returning it from an UDF</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.sqlite-udf-encode-binary-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>sqlite_udf_encode_binary</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>sqlite_udf_encode_binary()</strong></span> applies a binary encoding
   to the <code class="parameter">data</code> so that it can be safely returned from
   queries (since the underlying <var class="filename">libsqlite</var> API is not binary safe).
  </p>
  <p class="para">
   If there is a chance that your data might be binary unsafe (e.g.: it
   contains a NUL byte in the middle rather than at the end, or if it has and
   <em>0x01</em> byte as the first character) then you must
   call this function to encode the return value from your UDF.
  </p>
  <p class="para">
   PHP does not perform this encode/decode operation automatically as it would
   severely impact performance if it did.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Do not use <span class="function"><a href="sqlite_escape_string.html" class="function">sqlite_escape_string()</a></span> to quote strings
    returned from UDF&#039;s as it will lead to double-quoting of the data.  Use
    <span class="function"><strong>sqlite_udf_encode_binary()</strong></span> instead!
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.sqlite-udf-encode-binary-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">data</code></dt>

     <dd>

      <p class="para">
       The <span class="type"><a href="language.types.string.html" class="type string">string</a></span> being encoded.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.sqlite-udf-encode-binary-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The encoded <span class="type"><a href="language.types.string.html" class="type string">string</a></span>.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.sqlite-udf-encode-binary-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="sqlite_udf_decode_binary.html" class="function" rel="rdfs-seeAlso">sqlite_udf_decode_binary()</a> - Decode binary data passed as parameters to an UDF</span></li>
    <li class="member"><span class="function"><a href="sqlite_escape_string.html" class="function" rel="rdfs-seeAlso">sqlite_escape_string()</a> - Escapes a string for use as a query parameter</span></li>
    <li class="member"><span class="function"><a href="sqlite_create_function.html" class="function" rel="rdfs-seeAlso">sqlite_create_function()</a> - Registers a &quot;regular&quot; User Defined Function for use in SQL statements</span></li>
    <li class="member"><span class="function"><a href="sqlite_create_aggregate.html" class="function" rel="rdfs-seeAlso">sqlite_create_aggregate()</a> - Register an aggregating UDF for use in SQL statements</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>